<?php
require('../../../lib/base.php');
$base=new base('web');
$data['id']=intval($base->get('id'));
$data['sort']=intval($base->get('sort'));
$data['parent']=intval($base->get('parent'));
$data['menu']=$base->cache(array('tag'=>'web.header','time'=>86400));
$data['menu']=unserialize($data['menu']);
$data['foot']=$base->cache(array('tag'=>'web.footer','time'=>86400));
$sort=$base->model('sort');
$data['help']=$sort->GSort(array('where'=>array('label='=>'content','parent='=>$data['parent'],'locked='=>0),'order'=>array('sequence'=>'DESC')));
$content=$base->model('content');
if($data['id']!=0){
	$data['detail']=reset($content->GContent(array('where'=>array('id='=>$data['id']))));
}else if($data['sort']!=0){
	$pams=array('select'=>'id,title','where'=>array('sort='=>$data['sort']),'order'=>array('sequence'=>'DESC'),'limit'=>array(intval($base->get('start')),15));
	$data['total']=$content->GContent(array('select'=>'COUNT(*) AS count','where'=>$pams['where']));
	$data['total']=empty($data['total'])?0:$data['total'][0]['count'];
	$data['content']=$content->GContent($pams);
	$pagination=$base->library('pagination',array('base_url'=>domain.'view/help.php?','total_rows'=>$data['total'],'per_page'=>15,'first_link'=>'首页','last_link'=>'末页','cur_tag_open'=>'<a href="#" class="active">','cur_tag_close'=>'</a>'));
	$data['pagination']=$pagination->create_links();
}else{
	$temp=array();
	foreach($data['help'] as $value){$temp[]=$value['id'];}
	$data['content']=$content->GContent(array('where'=>array('sort IN'=>$temp),'order'=>array('sequence'=>'DESC'),'limit'=>array(0,15)));
}
$base->set($data);
$base->view('view/help.php');
?>